package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TAdmissionRegistrationMapper;
import com.ruoyi.system.domain.TAdmissionRegistration;
import com.ruoyi.system.service.ITAdmissionRegistrationService;
import com.ruoyi.common.core.text.Convert;

/**
 * 住院登记Service业务层处理
 * 
 * @author 杨一迪
 * @date 2024-12-29
 */
@Service
public class TAdmissionRegistrationServiceImpl extends ServiceImpl<TAdmissionRegistrationMapper,TAdmissionRegistration> implements ITAdmissionRegistrationService

{
    @Autowired
    private TAdmissionRegistrationMapper tAdmissionRegistrationMapper;

    /**
     * 查询住院登记
     * 
     * @param id 住院登记主键
     * @return 住院登记
     */
    @Override
    public TAdmissionRegistration selectTAdmissionRegistrationById(Long id)
    {
        return tAdmissionRegistrationMapper.selectTAdmissionRegistrationById(id);
    }

    /**
     * 查询住院登记列表
     * 
     * @param tAdmissionRegistration 住院登记
     * @return 住院登记
     */
    @Override
    public List<TAdmissionRegistration> selectTAdmissionRegistrationList(TAdmissionRegistration tAdmissionRegistration)
    {
        return tAdmissionRegistrationMapper.selectTAdmissionRegistrationList(tAdmissionRegistration);
    }

    /**
     * 新增住院登记
     * 
     * @param tAdmissionRegistration 住院登记
     * @return 结果
     */
    @Override
    public int insertTAdmissionRegistration(TAdmissionRegistration tAdmissionRegistration)
    {
        tAdmissionRegistration.setCreateTime(DateUtils.getNowDate());
        return tAdmissionRegistrationMapper.insertTAdmissionRegistration(tAdmissionRegistration);
    }

    /**
     * 修改住院登记
     * 
     * @param tAdmissionRegistration 住院登记
     * @return 结果
     */
    @Override
    public int updateTAdmissionRegistration(TAdmissionRegistration tAdmissionRegistration)
    {
        tAdmissionRegistration.setUpdateTime(DateUtils.getNowDate());
        return tAdmissionRegistrationMapper.updateTAdmissionRegistration(tAdmissionRegistration);
    }

    /**
     * 批量删除住院登记
     * 
     * @param ids 需要删除的住院登记主键
     * @return 结果
     */
    @Override
    public int deleteTAdmissionRegistrationByIds(String ids)
    {
        return tAdmissionRegistrationMapper.deleteTAdmissionRegistrationByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除住院登记
     *
     * @param ids 需要软删除的住院登记主键
     * @return 结果
     */
    @Override
    public int softDeleteTAdmissionRegistrationByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            TAdmissionRegistration tAdmissionRegistration = tAdmissionRegistrationMapper.selectTAdmissionRegistrationById(Long.valueOf(s));
            tAdmissionRegistration.setIsDelete(1);
            int i = tAdmissionRegistrationMapper.updateTAdmissionRegistration(tAdmissionRegistration);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除住院登记信息
     * 
     * @param id 住院登记主键
     * @return 结果
     */
    @Override
    public int deleteTAdmissionRegistrationById(Long id)
    {
        return tAdmissionRegistrationMapper.deleteTAdmissionRegistrationById(id);
    }
}
